package com.btl.component.crypto;

import com.btl.component.crypto.advice.DecryptRequestBodyAdvice;
import com.btl.component.crypto.advice.EncryptResponseBodyAdvice;
import com.btl.component.crypto.endpoint.CryptoController;
import com.btl.component.crypto.handler.CryptExceptionHandler;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;


@AutoConfiguration
//@ConditionalOnExpression("!('${spring.profiles.active}' matches 'dev|prod')")
@Profile("!dev")
public class CryptoAutoConfig {

    @Bean
    @ConditionalOnWebApplication
    public DecryptRequestBodyAdvice decryptRequestBodyAdvice() {
        return new DecryptRequestBodyAdvice();
    }

    @Bean
    @ConditionalOnWebApplication
    public EncryptResponseBodyAdvice encryptResponseBodyAdvice() {
        return new EncryptResponseBodyAdvice();
    }


    @Bean
    @ConditionalOnWebApplication
    public CryptExceptionHandler cryptExceptionHandler() {
        return new CryptExceptionHandler();
    }

    @Bean
    @Profile("test")
    public CryptoController cryptoController() {
        return new CryptoController();
    }


}
